//
//  StoreViewController.m
//  HomePage
//
//  Created by xiong qi on 13-5-3.
//  Copyright (c) 2013年 winston. All rights reserved.
//

#import "StoreViewController.h"
#import "StoreDetailViewController.h"
#import "MemberCampaignViewController.h"

@interface StoreViewController ()

@end

@implementation StoreViewController

-(id)initWithFrame:(CGRect)frame
{
    self = [super init];
    if (self)
    {
        self.view.frame = frame;
        
        UIImageView * background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,1024, 768)];
        [self.view addSubview:background];
        [background release];
        [background setImage:[UIImage imageNamed:@"AllAuto_Image_BG"]];
        
        storeview = [[Store_View alloc] initWithFrame:CGRectMake(0, 0,1024, 768)];
        [self.view addSubview:storeview];
        [storeview release];
        
        UIButton *  backBtn = [[UIButton alloc]initWithFrame:CGRectMake(50, 18, 55,40)];
        [backBtn setImage:[UIImage imageNamed:@"home_button"] forState:UIControlStateNormal];
        [backBtn addTarget:self action:@selector(onBack:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:backBtn];
        [backBtn release];
        
        
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onGoStorePage:) name:Notification_Navigate_To_Store object:nil];
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onGoMemberPage:) name:Notification_Navigate_To_Member object:nil];
    }
    return self;
}


-(void)onBack:(id)sender
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)onGoStorePage:(NSNotification*)notify
{
    NSDictionary * dic = (NSDictionary *)[notify object];
    StoreDetailViewController * Controller = [[StoreDetailViewController alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) Object:dic];
    //[self.navigationController pushViewController:Controller animated:YES];
    [Controller release];
}

-(void)onGoMemberPage:(NSNotification*)notify
{
//    NSArray * array = (NSArray *)[notify object];
    NSDictionary * dic = (NSDictionary *)[notify object];
    MemberCampaignViewController * Controller = [[MemberCampaignViewController alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) Object:dic];
    //[self.navigationController pushViewController:Controller animated:YES];
    [Controller release];
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
    [super dealloc];
}

@end
